package cn.qiao.dubbo.provider.service.impl;

import cn.qiao.dubbo.provider.service.BaseService;
import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ReferenceConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.utils.ReferenceConfigCache;
import com.alibaba.dubbo.rpc.service.GenericService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * desc:
 *
 * @author qiao
 * @date 2023年07月08日 17:55
 */
@Service
public class BaseServiceImpl implements BaseService {


    @Override
    public Object demo() {
        return null;
    }

    public Map<String, Object> doSelectArAuditAccSensitiveSingleLogList(Integer pageNum, Integer pageSize) {
        ApplicationConfig application = new ApplicationConfig();
        application.setName("consumer");

        RegistryConfig registry = new RegistryConfig();
        //设置注册中心地址
        registry.setAddress("");

        ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
        reference.setApplication(application);
        reference.setRegistry(registry);
        //接口名
        reference.setInterface("service.api.DataTableAuditManageService");
        reference.setGeneric(true);
        ReferenceConfigCache cache = ReferenceConfigCache.getCache();
        GenericService genericService = cache.get(reference);
        //请求参数
        String[] parameterTypes = new String[]{"service.api.request.AuditAccSensitiveSingleLogRequest"};

        Map params = new HashMap();
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        Object result = genericService.$invoke("selectArAuditAccSensitiveSingleLogList", parameterTypes, new Object[]{params});
        if (result != null) {
            Map<String, Object> resultMap = (HashMap) result;
            return resultMap;
        }
        return null;
    }
}
